import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(29, GPIO.OUT)    # 设置GPIO 1为输出
pwm = GPIO.PWM(29, 6666)     # 设置GPIO 5为PWM输出, 脉冲为4978Hz
pwm.start(0)
pwm.ChangeDutyCycle(50)     # 持续发出脉冲电平
time.sleep(0.5)     # 持续0.5s声音
pwm.stop()

GPIO.cleanup()


# 四分音符间隔时间为 1s
quarter = 1
# 八分音符间隔时间为 0.5s
eighth = 0.5

notation = [
    # 前奏 2022年7月18日14:58:26
    # 3166 * 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    # 3177 * 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    # 3166 再乘4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    # 3277 * 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    # 3166 再再乘 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_A5', 0.5 * eighth],  # high 6

    # 3177 * 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_B5', 0.5 * eighth],  # high 7

    # 日出在印象的港口来回
    ['NOTE_AS4', 0.5 * eighth],  # 6#
    ['NOTE_AS4', 0.5 * eighth],  # 6#
    ['NOTE_AS4', 0.5 * eighth],  # 6#
    ['NOTE_AS4', 0.5 * eighth],  # 6#
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_F5', 0.5 * eighth],  # high 4
    ['0', 0.5 * eighth],  # 0
    ['NOTE_A4', quarter],  # 6
    ['NOTE_G4', eighth],  # 5
    ['0', eighth],  # 0

    # 光线唤醒了睡着的花叶
    ['NOTE_A2', eighth],  # low low 6
    ['NOTE_E3', eighth],  # low 3
    ['NOTE_A3', eighth],  # low 6
    ['NOTE_E3', eighth],  # low 3
    ['NOTE_A2', eighth],  # low low 6
    ['NOTE_E3', eighth],  # low 3
    ['NOTE_A3', eighth],  # low 6
    ['NOTE_E3', eighth],  # low 3
    ['NOTE_C5', quarter],  # high 1
    ['NOTE_G4', eighth],  # 5

    # ----------------- (钢琴伴奏--周董) ---------
    ['NOTE_A5', 0.5 * eighth],  # high 6
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_E4', 0.5 * eighth],  # 3
    ['NOTE_A4', 0.5 * eighth],  # 6

    ['NOTE_C4', 0.5 * eighth],  # 1
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_E4', 0.5 * eighth],  # 3
    ['NOTE_A4', 0.5 * eighth],  # 6

    ['NOTE_E5', 1.5 * eighth],  # high 3
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_E4', 0.5 * eighth],  # 3
    ['NOTE_A4', 0.5 * eighth],  # 6

    ['NOTE_G5', 1.5 * eighth],  # high 5
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_F5', 0.5 * eighth],  # high 4
    ['NOTE_G5', 0.5 * eighth],  # high 5

    ['NOTE_D4', 0.5 * eighth],  # 2
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_F4', 0.5 * eighth],  # 4
    ['NOTE_A4', 0.5 * eighth],  # 6

    ['NOTE_D4', 0.5 * eighth],  # 2
    ['NOTE_A4', 0.5 * eighth],  # 6
    ['NOTE_F5', 0.5 * eighth],  # high 4
    ['NOTE_A5', 0.5 * eighth],  # high 6

    ['NOTE_D4', 0.5 * eighth],  # 2
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_F5', 0.5 * eighth],  # high 4

    # 中间间隔（等待郎朗演奏）
    ['0', quarter],  # 0
    ['0', quarter],
    ['0', quarter],
    ['0', quarter],
    ['0', quarter],

    # ------------------ (钢琴伴奏-郎朗) -----------------
    ['NOTE_G5', 0.5 * eighth],  # high 5
    ['NOTE_G4', 0.5 * eighth],  # 5
    ['NOTE_D4', 0.5 * eighth],  # 2
    ['NOTE_G4', 0.5 * eighth],  # 5

    ['NOTE_D4', eighth],  # 2
    ['NOTE_CS4', 0.5 * eighth],  # 1#
    ['NOTE_D4', 0.5 * eighth],  # 2

    ['NOTE_G4', 0.5 * eighth],  # 5
    ['NOTE_F4', 0.5 * eighth],  # 4
    ['NOTE_B4', 0.5 * eighth],  # 7
    ['NOTE_D5', 0.5 * eighth],  # high 2

    ['NOTE_G5', 0.5 * eighth],  # high 5
    ['NOTE_F5', 0.5 * eighth],  # high 4
    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2

    ['NOTE_E5', 0.5 * eighth],  # high 3
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_B4', 0.5 * eighth],  # 7

    ['NOTE_C4', 0.5 * eighth],  # 1
    ['NOTE_E4', 0.5 * eighth],  # 3
    ['NOTE_G4', 0.5 * eighth],  # 5
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_E4', 2 * eighth],  # 3

    # （音太高了不好听）--------------------------------- 纯音乐背景（更高音）2022年7月18日14:21:24 ----------------------
    # （小船静静往返）high
    ['0', eighth],  # 0
    ['NOTE_E5', eighth],  # high 3
    ['NOTE_A5', eighth],  # high 6
    ['NOTE_E6', eighth],  # high high 3
    ['NOTE_E6', 1.5 * eighth],  # high high 3
    ['NOTE_D6', 0.5 * eighth],  # high high 2
    ['NOTE_F6', quarter],  # high high 4

    # 马蹄斯的海岸
    ['0', eighth],  # 0
    ['NOTE_E5', eighth],  # high 3
    ['NOTE_GS5', eighth],  # high 5#
    ['NOTE_D6', eighth],  # high high 2
    ['NOTE_D6', 1.5 * eighth],  # high high 2
    ['NOTE_C6', 0.5 * eighth],  # high high 1
    ['NOTE_E6', quarter],  # high high 3

    # 星空下的夜晚
    ['0', eighth],  # 0
    ['NOTE_E5', eighth],  # high 3
    ['NOTE_A5', eighth],  # high 6
    ['NOTE_C6', eighth],  # high high 1
    ['NOTE_C6', 1.5 * eighth],  # high high 1
    ['NOTE_B5', 0.5 * eighth],  # high 7
    ['NOTE_D6', quarter],  # high high 2

    # 交给梵谷点燃
    ['0', eighth],  # 0
    ['NOTE_E4', eighth],  # high 3
    ['NOTE_FS5', eighth],  # high 4#
    ['NOTE_C6', eighth],  # high high 1
    ['NOTE_C6', 1.5 * eighth],  # high high 1
    ['NOTE_D6', 0.5 * eighth],  # high high 2
    ['NOTE_B5', quarter],  # high 7

    # 梦美的太短暂
    ['0', eighth],  # 0
    ['NOTE_AS5', 0.5 * eighth],  # high 6#
    ['NOTE_B5', 0.5 * eighth],  # high 7
    ['NOTE_GS6', 0.5 * eighth],  # high high 5#
    ['NOTE_FS6', 0.5 * eighth],  # high high 4#
    ['NOTE_E6', 0.5 * eighth],  # high high 3
    ['NOTE_E6', 1.5 * eighth],  # high high 3
    ['0', 0.5 * eighth],  # high high 2
    ['NOTE_B6', quarter],  # high high 7

    # ---
    # 孟克桥上呐喊
    ['0', eighth],  # 0
    ['NOTE_C7', eighth],  # high high high 1
    ['NOTE_B6', eighth],  # high high 7
    ['NOTE_E6', eighth],  # high high 3
    ['NOTE_D6', 1.5 * eighth],  # high high 2
    ['NOTE_E6', 0.5 * eighth],  # high high 3
    ['NOTE_C6', quarter],  # high high 1

    # 这世上的热闹
    ['0', eighth],  # 0
    ['NOTE_C6', 0.5 * eighth],  # high high 1
    ['NOTE_D6', 0.5 * eighth],  # high high 2
    ['NOTE_C6', 0.5 * eighth],  # high high 1
    ['NOTE_B5', eighth],  # high 7
    ['NOTE_C6', 0.5 * eighth],  # high high 1
    ['NOTE_E6', eighth],  # high high 3
    ['NOTE_D6', 0.5 * eighth],  # high high 2
    ['NOTE_A5', 1.5 * quarter],  # high 6

    # 出自孤单
    ['NOTE_E5', eighth],  # high 3
    ['NOTE_C6', 1.5 * eighth],  # high high 1
    ['NOTE_B5', 0.5 * eighth],  # high 7
    ['NOTE_A5', quarter],  # high 6
    ['NOTE_C5', eighth],  # high 1
    ['NOTE_B4', eighth],  # 7
    ['NOTE_A4', 2 * quarter],  # 6

    # 花园流淌的阳光
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1

    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['0', 0.5 * eighth],  # high 0

    # 空气摇曳着花香
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1

    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['NOTE_C5', 0.5 * eighth],  # high 1
    ['NOTE_D5', 0.5 * eighth],  # high 2
    ['0', 0.5 * eighth],  # high 0

    # 过渡一下，最后再来一遍高潮部分结尾
    ['NOTE_G4', eighth],  # 5
    ['NOTE_AS4', 0.5 * eighth],  # 6#
    ['NOTE_A4', eighth],  # 6
    ['NOTE_C5', eighth],  # high 1
    ['NOTE_A4', eighth],  # 6

    ['NOTE_G4', eighth],  # 5
    ['NOTE_A4', eighth],  # 6
    ['NOTE_E3', eighth],  # low 3

]
